//
//  VideoViewController.m
//  GSG
//
//  Created by dllo on 15/4/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "VideoViewController.h"
#import "MBProgressHUD.h"
#import "AFSoundManager.h"
#import "AFAudioRouter.h"
#import"singleSong.h"
#import"MoveViewController.h"
@interface VideoViewController ()<UIWebViewDelegate>
{
    
    UIWebView *webView;
    
    UIActivityIndicatorView *activityIndicatorView;
    
}
@property(nonatomic,retain)MBProgressHUD *HUD;
@end

@implementation VideoViewController
-(void)action1{
    
   
    NSNotificationCenter *center=[NSNotificationCenter  defaultCenter];
    
    [center postNotificationName:@"不隐藏" object:@"收到了看见了" userInfo:nil];
  
   [self.navigationController popViewControllerAnimated:YES];
}
    
- (void)viewDidLoad {
  
    [super viewDidLoad];
    
    
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]
                                   initWithTitle:@"返回"
                                   style:UIBarButtonItemStylePlain
                                   target:self
                                   action:@selector(action1)];
    [self.navigationItem setLeftBarButtonItem:leftButton];
    
       NSNotificationCenter *center=[NSNotificationCenter  defaultCenter];
    [center postNotificationName:@"隐藏" object:@"收到了看见了" userInfo:nil];

    NSNotificationCenter *center1=[NSNotificationCenter  defaultCenter];
    [center1 postNotificationName:@"暂停" object:@"收到了看见了" userInfo:nil];
    
    
   // [[AFSoundManager sharedManager]pause];
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bujing.png"]];

    // Do any additional setup after loading the view.
//    activityIndicatorView = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0.0, 0.0, 100, 100)];
//    activityIndicatorView.backgroundColor = [UIColor whiteColor];
//    [activityIndicatorView setCenter: self.view.center];
//    [activityIndicatorView setActivityIndicatorViewStyle: UIActivityIndicatorViewStyleGray];
//    [self.view addSubview : activityIndicatorView];

//    

    

    
    //1.创建网络请求
    NSString *str = self.musicModel.url_low;
    //    NSLog(@"%@",self.musicModel.url_low);
    NSURL *url =[NSURL URLWithString:str];
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

//    webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"button1.jpg"]];
//    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height)];
//    [image setImage:[UIImage imageNamed:@"af.png"]];
//    [webView addSubview:image];
    

  //  webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"button1.jpg"]];
//    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height)];
//    [image setImage:[UIImage imageNamed:@"af.png"]];
//    [webView addSubview:image];

    //2.设置WebView的代理
    webView.delegate = self;
    //伸缩内容适应屏幕尺寸
    webView.scalesPageToFit = NO;
    //加载网络请求
    [webView loadRequest:request];
   
    
   //    UIButton *bu=[UIButton buttonWithType:UIButtonTypeSystem];
//    bu.frame=CGRectMake(0, 0, 60, 60);
//    bu.backgroundColor=[UIColor whiteColor];
//    [bu addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];
//    [webView addSubview:bu];
    
    
    [self.view addSubview:webView];
    
    

}

// WebView开始加载资源的时候调用（开始发送请求）
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"开始加载");
    
    //小菊花
    //方式1.直接在View上show
    _HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain];
    
    
    //常用的设置
    //小矩形的背景色
    _HUD.color = [UIColor clearColor];//这儿表示无背景
    //显示的文字
    _HUD.labelText = @"提示";
    //细节文字
    _HUD.detailsLabelText = @"正在加载内容";
    //是否有庶罩
    _HUD.dimBackground = YES;
    [activityIndicatorView startAnimating] ;
}
// WebView加载完毕的时候调用（请求完毕）
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSLog(@"结束加载");
    [_HUD hide:YES];
   // [activityIndicatorView stopAnimating];
 
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
